package com.go.where.family.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.go.where.family.constants.Constant;
import com.go.where.family.dao.FamilySquareDao;
import com.go.where.family.pojo.FamilySquareInfo;
import com.go.where.family.service.FamilySquareService;

@Service("familySquareService")
public class FamilySquareServiceImpl implements FamilySquareService {

	@Resource(name = "familySquareDao")
	private FamilySquareDao familySquareDao;

	@Override
	public List<FamilySquareInfo> queryList(Map<String, Object> map) {
		return familySquareDao.queryT(map);
	}

	@Override
	public int save(FamilySquareInfo familySquareInfo) {
		familySquareInfo.setId(UUID.randomUUID().toString());
		familySquareInfo.setPublishTime(new Date());
		familySquareInfo.setIsDelete(Constant.IS_NOT_DELETE);
		return familySquareDao.insert(familySquareInfo);
	}

	@Override
	public int update(FamilySquareInfo familySquareInfo) {
		return familySquareDao.update(familySquareInfo);
	}

	@Override
	public FamilySquareInfo queryDetailSquare(String id) {
		FamilySquareInfo fsi = new FamilySquareInfo();
		fsi.setId(id);
		return familySquareDao.queryByPrimaryKey(fsi);
	}

}
